package com.bwie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.mapper.SubscribeMapper;
import com.bwie.pojo.Subscribe;
import com.bwie.service.SubscribeService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Date;

/**
 * TODO
 *
 * @Description
 * @Author 36167
 * @Date 2025/3/6 11:23
 **/

@Service
public class SubscribeServiceImpl extends ServiceImpl<SubscribeMapper, Subscribe> implements SubscribeService {

    @Autowired
    SubscribeMapper subscribeMapper;

    @Override
    public int subadd(Subscribe subscribe) {
        subscribe.setTime(new Date());
      int i=  subscribeMapper.insert(subscribe);
      return i;
    }

    @Override
    public R delByid(String id) {
        String[] split = id.split(",");
        int i = subscribeMapper.deleteBatchIds(Arrays.asList(split));
        return i>0?R.OK("删除成功"):R.ERROR(500,"删除失败");
    }
}
